import time
import unittest
#from test import test_support


import sys
sys.path = [".."] + sys.path
import UAI
import Main
from Person import Person
from Box import Box
import pygame
import time

class UAITest(unittest.TestCase):
    def setUp(self):
        self.maxtesttime = 6
        Main.Init('../data/')
    
    def loopWithTest(self, test):  
        print
        starttime = time.time()
        while not UAI.QUIT:
            UAI.clock.tick(60)
            UAI.event.handleEvents()
            if not UAI.PAUSE:
                UAI.game.run()
                UAI.window.draw()
                UAI.game.draw()
            pygame.display.flip()
            if test():
                print str(round(time.time() - starttime, 4)) + " seconds."
                return True
            if int(time.time()) - starttime > self.maxtesttime:
                self.fail('Timeout')
